package com.eclipse.training.model;

import java.util.ArrayList;

public class Universe {
	private DarkMatter darkMatter;
	private ArrayList<GalaxyCluster> galaxiesClusters = new ArrayList<GalaxyCluster>();

	public static Object createModelInput() {

		Universe universe = new Universe();
		universe.setDarkMatter(new DarkMatter("This strange thing!"));
		universe.setGalaxiesClusters(createGalaxiesClusters());

		return universe;
	}

	private static ArrayList<GalaxyCluster> createGalaxiesClusters() {
		ArrayList<GalaxyCluster> gC = new ArrayList<GalaxyCluster>();

		GalaxyCluster cluster = new GalaxyCluster("Virgo");
		cluster.setGalaxies(createGalaxies());
		gC.add(cluster);

		gC.add(new GalaxyCluster("Bullet"));
		gC.add(new GalaxyCluster("Pandora"));
		gC.add(new GalaxyCluster("Phoenix"));

		return gC;
	}

	private static ArrayList<Galaxy> createGalaxies() {
		ArrayList<Galaxy> galaxies = new ArrayList<Galaxy>();

		Galaxy galaxy = new Galaxy("Milky Way", "", "Sagittarius");
		galaxy.setNebulae(createNebulae());
		galaxy.setStarClusters(createStarClusters());
		galaxy.setStars(createStars());
		galaxies.add(galaxy);

		galaxy = new Galaxy("Andromeda", "M32", "Andromeda");
		galaxies.add(galaxy);

		galaxy = new Galaxy("Sombrero", "M104", "Virgo");
		galaxies.add(galaxy);

		galaxy = new Galaxy("Pinwheel", "M101", "Ursa Major");
		galaxies.add(galaxy);

		galaxy = new Galaxy("Whirlpool", "M51a", "Canes Venatici");
		galaxies.add(galaxy);

		galaxy = new Galaxy("Cartwheel", "ESO 350-40", "Sculptor");
		galaxies.add(galaxy);

		galaxy = new Galaxy("Sunflower", "NGC 5055", "Canes Venatici");
		galaxies.add(galaxy);

		return galaxies;
	}

	private static ArrayList<Star> createStars() {
		ArrayList<Star> stars = new ArrayList<Star>();

		Star star = new Star("Aldebaran", Star.CLS_K);
		stars.add(star);
		star = new Star("Sun", Star.CLS_G);
		star.setSystems(createSolarSystem());
		stars.add(star);
		star = new Star("Rigel", Star.CLS_B);
		stars.add(star);
		star = new Star("Pollux", Star.CLS_K);
		stars.add(star);
		star = new Star("Polaris", Star.CLS_F);
		stars.add(star);
		star = new Star("Mizar", Star.CLS_A);
		stars.add(star);
		star = new Star("Vega", Star.CLS_A);
		stars.add(star);
		star = new Star("Betelgeuse", Star.CLS_M);
		stars.add(star);

		return stars;
	}

	private static SolarSystem createSolarSystem() {
		SolarSystem system = new SolarSystem("Solar System");

		system.setAsteroids(createAsteroids());
		system.setPlanets(createPlanets());

		return system;
	}

	private static ArrayList<Planet> createPlanets() {

		ArrayList<Planet> planets = new ArrayList<Planet>();

		Planet planet = new Planet("Earth", 1.0f, 0.99f);
		planet.setSatellites(createSatellites());
		planets.add(planet);
		planet = new Planet("Mercury", 0.24f, 58.64f);
		planets.add(planet);
		planet = new Planet("Venus", 0.61f, -243.01f);
		planets.add(planet);
		planet = new Planet("Mars", 1.88f, 1.025f);
		planets.add(planet);
		planet = new Planet("Jupiter", 11.86f, 0.41f);
		planets.add(planet);
		planet = new Planet("Saturn", 29.44f, 0.44f);
		planets.add(planet);
		planet = new Planet("Uranus", 84.01f, -0.71f);
		planets.add(planet);
		planet = new Planet("Neptune", 164.29f, 0.67f);
		planets.add(planet);

		return planets;
	}

	private static ArrayList<Satellite> createSatellites() {
		ArrayList<Satellite> satellites = new ArrayList<Satellite>();

		Satellite satellite = new Satellite("Moon", 27.32f, 29.53f);
		satellites.add(satellite);

		return satellites;
	}

	private static ArrayList<Asteroid> createAsteroids() {
		ArrayList<Asteroid> asteroids = new ArrayList<Asteroid>();

		Asteroid asteroid = new Asteroid("Ceres");
		asteroids.add(asteroid);
		asteroid = new Asteroid("Pallas");
		asteroids.add(asteroid);
		asteroid = new Asteroid("Vesta");
		asteroids.add(asteroid);

		return asteroids;
	}

	private static ArrayList<StarCluster> createStarClusters() {
		ArrayList<StarCluster> clusters = new ArrayList<StarCluster>();

		StarCluster cluster = new StarCluster("Westerlund");
		clusters.add(cluster);
		cluster = new StarCluster("Great Globular Cluster of Hercules");
		clusters.add(cluster);
		cluster = new StarCluster("Plejades");
		clusters.add(cluster);

		return clusters;
	}

	private static ArrayList<Nebula> createNebulae() {
		ArrayList<Nebula> nebulae = new ArrayList<Nebula>();

		Nebula nebula = new Nebula("Ring", "M57", "Lyra");
		nebulae.add(nebula);
		nebula = new Nebula("Butterfly", "M2-9", "Ophiuchus");
		nebulae.add(nebula);
		nebula = new Nebula("Little Ghost", "NGC6369", "Ophiuchus");
		nebulae.add(nebula);
		nebula = new Nebula("Orion", "M42", "Orion");
		nebulae.add(nebula);

		return nebulae;
	}

	public DarkMatter getDarkMatter() {
		return darkMatter;
	}

	public void setDarkMatter(DarkMatter darkMatter) {
		this.darkMatter = darkMatter;
	}

	public ArrayList<GalaxyCluster> getGalaxiesClusters() {
		return galaxiesClusters;
	}

	public void setGalaxiesClusters(ArrayList<GalaxyCluster> galaxiesClusters) {
		this.galaxiesClusters = galaxiesClusters;
	}

}
